import time
from Po163_0904.Base import Base
from Po163_0904.Page import Page
from selenium.webdriver.common.by import By

class Page2(Page):
    # 进入框架
    kj_loc = (By.XPATH, '/html/body/div[3]/div[3]/div[1]/div/div[3]/div[1]/div[2]/iframe')
    def kj(self):
        self.frame(self.kj_loc)
    # 断言
    dy_loc = (By.XPATH, '/html/body/div[3]/div[3]/div[1]/div/div[3]/h2')
    def dy(self):
        self.text(self.dy_loc)
    # 输入账号
    user_loc = (By.NAME, 'email')
    def username(self):
        self.send_keys(self.user_loc,'13381144084')
    # 输入密码
    pass_loc = (By.NAME, 'password')
    def password(self):
        self.send_keys(self.pass_loc,'grq200566++')
    # 点击登录
    login_loc = (By.XPATH, '//*[@id="dologin"]')
    def login(self):
        self.click(self.login_loc)
    # 写信
    xie_loc=(By.XPATH,'//*[@id="_mail_component_98_98"]/span[2]')
    def xie(self):
        self.click(self.xie_loc)
    # 收件人
    shou_loc=(By.XPATH,'/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[1]/div[1]/div/div[2]/div/input')
    def shou(self):
        self.send_keys(self.shou_loc,"2440154941@qq.com")
    # 主题
    zhu_loc=(By.XPATH,'/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[2]/div[1]/div/div/input')
    def zhu(self):
        self.send_keys(self.zhu_loc,'163邮箱poooooo')
    # 点击发送
    send_loc=(By.CSS_SELECTOR,'.nui-btn-text')
    def send(self):
        self.click(self.send_loc)

    # 163邮箱邮件发送成功逻辑
    def luoji_163_xiexin(self):
        self.kj()
        self.username()
        self.password()
        self.login()
        self.frame_content()
        time.sleep(2)
        self.frame_content()
        time.sleep(2)
        self.xie()
        time.sleep(2)
        self.shou()
        time.sleep(2)
        self.zhu()
        time.sleep(2)
        self.send()
        time.sleep(5)